mishka's clock

Charlie Veniot 18th September 2022 at 4:21pm
' Based on FREEBASIC program found at https://retrocoders.phatcode.net/index.php?topic=22.0;topicseen
' This BASIC Anywhere Machine version by Charlie Veniot

' #lang "qb"
'_TITLE "THE MATHEMATICAL ANALOG CLOCK VERSION 3 - WITHOUT CALIBRATION"
SCREEN _NEWIMAGE(470, 460, 12)
'DEVELOPED 2/17/2019 IN QBASIC BY RON77 AND MISHKA AND ITAY :)
'screen half with & height
const SHW = 470 \ 2
const SHH = 460 \ 2
const pi = 3.14159265
const RAD_PER_DEG = 2 * pi / 360

Sub clock()
   DO
      '
      hour = VAL(LEFT$(TIME$, 2))
      minute = VAL(MID$(TIME$, 4, 2))
      sec = VAL(RIGHT$(TIME$, 2))

      hour = hour + minute / 60 + sec / 3600
      minute = minute + sec / 60

      ts = 90 - sec * 6
      tm = 90 - minute * 6
      th = 90 - hour * 30

      CLS
'      PRINT TIME$
'      PRINT "press ESC to exit  "

      CIRCLE (SHW, SHH), 200, 14
      CIRCLE (SHW, SHH), 215, 14
      'draw minute marks
      FOR j = 0 TO 59
         cosangle = COS((90 - j * 6) * RAD_PER_DEG)
         sinangle = SIN((90 - j * 6) * RAD_PER_DEG)
         LINE (SHW + 190 * cosangle, SHH - 190 * sinangle)-(SHW + 200 * cosangle, SHH - 200 * sinangle), 11
      NEXT
      'draw hour marks
      FOR i = 0 TO 11
         cosangle = COS((90 - i * 30) * RAD_PER_DEG)
         sinangle = SIN((90 - i * 30) * RAD_PER_DEG)
         LINE (SHW + 205 * cosangle, SHH - 205 * sinangle)-(SHW + 210 * cosangle, SHH - 210 * sinangle), 14
      NEXT
      'draw pointers
      LINE (SHW, SHH)-(SHW + 200 * COS(ts * RAD_PER_DEG), (SHH - 200 * SIN(ts * RAD_PER_DEG))), 15
      LINE (SHW, SHH)-(SHW + 180 * COS(tm * RAD_PER_DEG), (SHH - 180 * SIN(tm * RAD_PER_DEG))), 11
      LINE (SHW, SHH)-(SHW + 120 * COS(th * RAD_PER_DEG), (SHH - 120 * SIN(th * RAD_PER_DEG))), 14
      SLEEP (1)

      k$ = INKEY$
   LOOP UNTIL k$ = CHR$(27)
END SUB

call clock()